<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <script>
      console.log(1); //同步
      const promise = new Promise((resolve, reject) => {
        setTimeout(function(){ 
          //思考：若没有定时，输出结果又如何，屏蔽这行和下边第3行 
          // 则console.log(2)是同步任务  1 2 3 5 7 4 6
          console.log(2); //宏任务
          resolve('success');
        }, 5000);//
      });
      console.log(3);//同步

      promise.then(function(res){
        console.log(4); //微任务
      });
      console.log(5); //同步

      promise.then(function(res){
        console.log(6); //微任务
      });
      console.log(7); //同步

      //1 3 5 7    2 4 6
    </script>
  </body>
</html>
